# It is recommended to test the script on a local machine for its purpose and effects. # ManageEngine Desktop Central will not be responsible for any # damage/loss to the data/setup based on the behavior of the script. # Description - Script to Delete Files older than X days # Parameters - " "" # Configuration Type - USER/COMPUTER if [ $# == '2' ]; then if [ -d "$1" ] then echo "Directory \"$1\" exists." else echo "Error: Directory \"$1\" does not exists." exit 2 fi folderPath=$1 days=$2 find $folderPath -ctime +$days -print0 | xargs -0 rm ret=$? if [ $ret == "0" ]; then echo "All files older than \"$2\" days are deleted" else echo "Error in executing the code" fi exit $ret else echo "Invalid Arguments - Please refer description of the script" exit 1 fi